package cn.jobstart.service.impl;

import cn.jobstart.vo.ResumeCapabilityLabelMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.jobstart.modelExt.ResumeCapabilityLabelExt;
import cn.jobstart.dao.IResumeCapabilityLabelDao;
import cn.jobstart.searchExt.ResumeCapabilityLabelSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeCapabilityLabelService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;


/**
*    @author sunke
*    @Date 2023-09-06 15:00:21
*    @description ResumeCapabilityLabelService      简历能力标签
*/
@Service(value = "resumeCapabilityLabelService")
@Slf4j
public class ResumeCapabilityLabelServiceImpl extends AbstractBaseService<ResumeCapabilityLabelExt, ResumeCapabilityLabelSearchExt,String> implements IResumeCapabilityLabelService {

    @Resource(name = "resumeCapabilityLabelDao")
    private IResumeCapabilityLabelDao resumeCapabilityLabelDao;

    @Override
    public IBaseDao<ResumeCapabilityLabelExt, ResumeCapabilityLabelSearchExt,String> getDao() {
        return resumeCapabilityLabelDao;
    }

    /**
     * 简历能力标签
     *
     * @param resumeId
     * @return
     */
    @Override
    public String getResumeCapabilityLabelStrByResumeId(String resumeId) {
        try {
            List<ResumeCapabilityLabelExt> labelList = getListByResumeId(resumeId);

            return StringUtil.getJsonArrayStrByList(labelList, ResumeCapabilityLabelMiniDomainVO.class);


        } catch (Exception e) {
            return "";
        }

    }

    /**
     * 根据简历ID查
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeCapabilityLabelExt> getListByResumeId(String resumeId) {
        if(StringUtil.isNullOrEmpty(resumeId)){
            return null;
        }
        ResumeCapabilityLabelSearchExt search=ResumeCapabilityLabelSearchExt.getInstance();
        search.setResumesIdEq(resumeId);
        try {
            return getAllList(search);
        } catch (SkException e) {
            return null;
        }
    }
}